home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.hope.edu!vnopstal
- From: vnopstal@cs.hope.edu (Michael Van Opstall)
- Newsgroups: comp.lang.c++
- Subject: [Q] Overloading >>
- Date: 10 Jan 1996 22:38:18 GMT
- Organization: Hope College
- Message-ID: <4d1f4q$7oj@news.cs.hope.edu>
- NNTP-Posting-Host: smaug.cs.hope.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- I was actually pretty clear on output stream overloading, but I really have
- a question on overloading the >> operator. I really just need the function
- header and param list. Right now, I'm using this:
-
- istream& operator>>(istream& in, typename t1)
-
- which compiles, but I don't understand what stream is which, nor what to
- do with t1. Am I supposed to do something like
-
- in >> whatever >> I >> want;
- t1.fpart=whatever;
- t1.mpart=I;
- t1.lpart=want;
- return in;
-
- or what? Why do I need to return an istream&? Same reason the = op requires
- a return?
-
- I'd love to be able to do a istream::Get and then parse the string and put
- it where it belongs in the object. That's why I'm concerned about returning
- a stream. This is ideally what I want. Is it kosher?
-
- char* input;
- in.Get(input, 80); // I know this isn't perfect syntax for Get...
-
- // ...parsing removed...//
- t1.fpart= ...something I got during parsing...
- etc.
- return in;
-
- Thanks in Advance for help
-
- --
- Michael A. Van Opstall -- vnopstal@cs.hope.edu
- http://www.cs.hope.edu/~vnopstal/deal.html - try it
-